import {useState,useEffect} from 'react'
import {api} from '../../luyou/index'
import styles from './cate.module.css'
import { useNavigate } from 'react-router-dom'
export default function Cate() {
  let navigate=useNavigate()
  const [list,setlist]= useState([])
  useEffect(()=>{
    getlist()
  },[])
  let getlist=async ()=>{
    let {data}=await api.get('/getlist2')
    console.log(data);
    if(data.code==200){
      setlist(data.data)
    }
  }
  return (
    <div>
      <h1>收藏</h1>
      {
        list.filter(item=>item.status==true).map(item=>{
          return <div key={item._id} className={styles.box} onClick={()=>navigate('/xiang?id='+item._id)}>
            <img style={{width:'2rem',height:'2rem'}} src={item.img} alt="" />
            <div>
              <h3>{item.name}</h3>
              <p>￥{item.price}</p>
            </div>

          </div>
        })
      }
    </div>
  )
}
